<meta name="viewport" charset="utf-8" content="width=device-width, initial-scale=1.0">
<?php
session_start();
$mysqli = mysqli_connect("localhost", "root", "123456", "library");
mysqli_query($mysqli,"SET NAMES 'utf8'");
$name = $_SESSION['adminno'];//用户名
$real_pwd = $_SESSION['password'];//真实密码
$past_pwd=$_REQUEST['past_pwd'];//原密码
$new_pwd=$_REQUEST['new_pwd'];//新密码
$pwd=$_REQUEST['password'];//第二次新密码
if($new_pwd==$pwd){
    if ($real_pwd == $past_pwd){
        $sql = "update admin set password = '$pwd' where adminno='$name'";
        $updatepwd = mysqli_query($mysqli,$sql);
        if ($updatepwd){
            echo '<script>alert("密码修改成功，请重新登录");location="index.html";</script>';
        }
        else{
            echo '<script>alert("未知错误！");location="pwd_reader.php";</script>';
        }
    }
    else{
        echo '<script>alert("原密码输入错误！");location="pwd_reader.php";</script>';
    }

}
else{
    echo '<script>alert("两次密码输入不相同！");location="pwd_reader.php";</script>';
}
//$infoQuery = mysqli_query($mysqli,$sql);
//$info = mysqli_fetch_row($infoQuery);
//$password = $info[0];//原密码

